<%@page language="java" contentType="text/html; charset=utf-8"%>
<%@include file="/tagDeclare.jsp"%>
<%@include file="/headDeclare.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>新增用户信息</title>
	<base href="<%=basePath%>"/>
	<style type="text/css"> 
	  fieldset,legend,form,table,tr,td,textarea{margin:0;padding:0}
	  form label {font-weight:bold;}
	  table{margin:10px 10px};
	  td{line-height: 40px;}
	  input[type="text"]{width:250px;}
	  input[type="password"]{width:250px;}
	  input[type="textarea"]{width:250px;}
	</style>

	<script type="text/javascript">
	  $(document).ready(function(){
		     
		     $('#itemValue').focus();
		     
		     $.ajaxSetup ({ cache:false,async: false });
		     
		     //异步提交表单
		     var options = {dataType: 'json', beforeSubmit: beforeSubmit, success: process};
		     $("#itemForm").submit(function(){
		         $(this).ajaxSubmit(options);
		          return false;
		     });   
		     
	  });
	 
	   //提交前验证
	   function beforeSubmit() {
		     if(isEmpty($("#itemValue").val())) { alert("行业名称不能为空！"); return false; }
		     return true;
	   }
	
	   function process(responseJson) {
		   if(responseJson.code == 0) {
		         $('#error_label').text("错误信息：" + responseJson.message);
		         $("#p_error").show();
		         return;
		     }
		     else
		     {   
         	     location.href = "<%=basePath%>item/list.do?groupName=trade";
		     }
	     
	   }  
	   //返回列表页面
	   function btn_return(){
	    	window.location.href="<%=basePath%>item/list.do?groupName=trade";
	   }
	  
	</script>
</head>
<body>
  <div style="margin-top: 10px;">
      <form id="itemForm" method="post" action="item/insert.do">
        <input id="groupName" name="groupName" type="hidden" value="trade"/>
      	<p id = "p_error" style = "margin:10px 10px;">
      	    <label id="error_label" style="color:red;"></label>
      	</p>
        <table>
		    <tr>
			    <td><label for="town">行业名称：</label></td>
				<td>
				   <input type="text" name="itemValue" id="itemValue" class="ldText" />
				</td>
			    <td><label for="password">行业代号：</label></td>
				<td>
				   <select id="itemName" name ="itemName" class="ldText" >
				   		<c:forEach begin="0" end="100" step="1" varStatus="i">
				   			<c:set var="flag" value="true" />
				   			<c:forEach items="${list }" var="item">
				   				<c:if test="${i.index ==item.itemName }">
				   					<c:set var="flag" value="false" />
				   				</c:if>
				   			</c:forEach>
				   			<c:if test="${flag}">
								<option value='${i.index}'><span>${i.index}</span></option>
							</c:if>
				   		</c:forEach>
				   </select>
				</td>
				<td></td>
				<td>
				    <input type="submit" id="btn_insert" value="提交" class="ldBtnBlue" />
				    <input type="button" id="btn_back" value="返回" onclick="btn_return();" class="ldBtnGray" />
				</td>
			</tr>
        </table>
      </form>
    </div>
</body>
</html>